package com.hry.store.cms.service.impl;

import com.hry.store.cms.dao.ProductVersionMapper;
import com.hry.store.cms.pojo.ProductVersion;
import com.hry.store.cms.pojo.SecondCategory;
import com.hry.store.cms.service.VersionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
@Service
public class VersionServiceImpl implements VersionService {

    @Autowired
    private ProductVersionMapper versionMapper;

    /**
     * 查询版本信息
     * @param secondCategoryId
     * @return
     */
    @Override
    public List<SecondCategory> getBySecondCategoryId(Integer secondCategoryId) {
        return versionMapper.selectBySecondCategoryId(secondCategoryId);
    }

    /**
     * 添加版本信息
     * @param secondCategoryId
     * @return
     */
    @Override
    public int addVersion(Integer secondCategoryId, String versionName, BigDecimal versionPrice) {
        ProductVersion version = new ProductVersion();
        version.setSecondCategoryId(secondCategoryId);
        version.setVersionPrice(versionPrice);
        version.setVersionName(versionName);
        return versionMapper.insertSelective(version);
    }
}
